﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HomeCare.Model;
using HomeCare.Control;

namespace HomeCare.View
{
    public partial class ConTela : Form
    {
        CadTela myParent = null;
        public ConTela(CadTela myParent)
        {
            InitializeComponent();
            this.myParent = myParent;
            dgvTela.Enabled = false;
        }

        private void ConTela_Load(object sender, EventArgs e)
        {
            
        }

        private void dgvTela_DoubleClick(object sender, EventArgs e)
        {
            Tela tela = new Tela();
            tela.id = Int32.Parse(dgvTela.SelectedRows[0].Cells["ID"].Value.ToString());
            tela.tela = dgvTela.SelectedRows[0].Cells["Tela"].Value.ToString();
            tela.descricao = dgvTela.SelectedRows[0].Cells["Descricao"].Value.ToString();

            myParent.RecebeTela(tela);
            Close();
        }

        private void btnConsultar_Click(object sender, EventArgs e)
        {
            Tela tela = new Tela();

            tela.tela = tbxTela.Text;
            TelaControl telaControl = new TelaControl();
            DataSet dataSet = telaControl.ConsultaTela(tela);
            dgvTela.Enabled = true;
            dgvTela.AutoGenerateColumns = true;
            dgvTela.ReadOnly = true;
            dgvTela.MultiSelect = false;
            dgvTela.DataSource = dataSet.Tables[0];
        }
    }
}
